home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / latexspider / web.doc (.txt) < prev    next >
LaTeX Document  |  1992-09-22  |  37KB  |  898 lines

  1. \iffalse % -*-latex-*-
  2. %% Copyright D.Love, SERC Daresbury Laboratory, 1991
  3. %% The `doc' version of this style is re-distributable and usuable
  4. %% under conditions of the GNU copyleft, but please mark any changes,
  5. %% list them here and report any major enhancements to the author.
  6. % This is a self-documenting style.  To produce the documentation you
  7. % might use a driver file like this:
  8. % \def\webmacs{null} \documentstyle[a4,makeidx,newdoc,web]{article}
  9. % \EnableCrossrefs \CodelineIndex
  10. % \begin{document} \DocInput{web.sty} \PrintIndex
  11. % \end{document}
  12. % and run `makeindex -s gind.ist doc' in between passes.  You need
  13. % Mittelbach's newdoc.sty at v1.6d or later.
  14. % To produce the .sty file use `latex docstrip' to remove most of the
  15. % comments.  Please don't distribute the .sty file without the .doc
  16. % file. 
  17. \iffalse %  hack RCS info into a sensible form:
  18. \def\next$#1: #2/#3/#4 #5 ${\def\filedate{#4/#3/#2}\def\filetime{#5}}
  19. \next$Date: 1991/06/19 10:28:40 $
  20. \def\next$#1: #2 ${\def\fileversion{#2}}
  21. \next$Revision: 1.2 $
  22. % \title{A a \web{} style file for \LaTeX{}\thanks{This file is version
  23. % \fileversion\ of \filedate}}
  24. % \author{David Love\\[2ex]{\it SERC Daresbury Laboratory, Warrington
  25. % WA4 4AD, UK}\\ \tt d.love@daresbury.ac.uk}
  26. % \date{}
  27. % \newcommand{\web}{{\tt WEB}}
  28. % \newcommand{\weave}{{\tt WEAVE}}
  29. % \newcommand{\tangle}{{\tt tangle}}
  30. % \newcommand{\spider}{Spider}
  31. % \MakeShortVerb{\"}
  32. % \DoNotIndex{\/,\@date,\@ifundefined,\@makefnmark,\@starttoc}
  33. % \DoNotIndex{\@topnum,\addpenalty,addvspace,\advance,aftergroup}
  34. % \DoNotIndex{\begin,\begingroup,\bgroup,\char,\def,\egroup,\else,\end}
  35. % \DoNotIndex{\endgroup,\fi,\fnsymbol,\hfil,\hfill,\hfilneg,\hss,\kern}
  36. % \DoNotIndex{\let,\lineskip,\newcommand,\protect,\qquad,\quad,\relax}
  37. % \DoNotIndex{\thanks,\thefootnote,\z@,\@M,\@thanks,\@thefnmark,\hbox}
  38. % \DoNotIndex{\empty,\mbox}
  39. % \maketitle
  40. % \begin{abstract} \noindent
  41. % This style file is for use with a version of the Spidery \weave\ system
  42. % that has been adapted to use \LaTeX\ rather than plain \TeX\ for the
  43. % formatting.  It is a first attempt.
  44. %  \end{abstract}
  45. % \section{Assumptions of \weave{} and the {\tt .web} file}
  46. % We assume we're using the version of Spidery \weave{} \cite{spider}
  47. % changed for \LaTeX\@.  This will write out
  48. % \begin{quote}"\def\webmacs{"\meta{ext}"web.tex}",\end{quote}
  49. % (where \meta{ext} is
  50. % the \spider{} {\tt extension}), then the limbo section, then
  51. % \begin{quote}"\begin{document}\maketitle" \end{quote}
  52. % the latter to stop you forgetting it.  The "\webmacs" file will be
  53. % included at the end of this style.
  54. % After the index (if any), we get
  55. % "\end{document}".  The user thus has to put the "\documentstyle"
  56. % command in the limbo part and include "web" in the style options to
  57. % get this stuff and can use other options as appropriate.  You're
  58. % meant to use the "article" main style, although I think "report"
  59. % would work too.
  60. % \section{Strategy}
  61. % The idea was to change the original \spider{} \TeX{} stuff as little
  62. % as possible, although it has actually been changed quite
  63. % substantially.  Changes are forced where there is a clash of macro 
  64. % names; most of the original one-character control sequences are
  65. % already used by \LaTeX, for instance.  Some features have been
  66. % converted to a \LaTeX{} equivalent, 
  67. % notably the table of contents mechanism, the title page, running
  68. % header and double-columning for the index.  For safety, "\def"s have
  69. % been replaced by "\newcommands" where possible since there are
  70. % probably plenty of possibilities for name clashes.
  71. % User-visible differences from the plain version are given in
  72. % appendix~\ref{changes}.
  73. % \section{Use with old webs}
  74. % Examples of the use of this style with old webs using the plain
  75. % conventions can be found in the accompanying changes files for
  76. % {\tt weave.web} and {\tt spider.web}.  You can use the limbo section
  77. % to check whether the generated ".tex" file is being run through
  78. % \LaTeX\ or plain \TeX\ by doing something like this:
  79. % \begin{quote}
  80. % \begin{verbatim}
  81. % \ifx\enddocument\undefined
  82. %   % plain things
  83. % \else
  84. %   % LaTeX things
  85. % \fi
  86. % \end{verbatim}
  87. % \end{quote}
  88. % \section{Bugs}
  89. % Floats
  90. % don't always come out where you'd expect due to interaction with
  91. % \web's attempts to keep all of a module on one page if possible.
  92. % "\str" and "\vstr", which 
  93. % might well get used in a moving argument, are 
  94. % fragile.  Module titles (after "@*") are moving arguments.  I think
  95. % if you use \web's "|"\dots"|" construction in a 
  96. % moving argument it will break and there's not much you can do about
  97. % it. 
  98. % \section{Code}
  99. % \subsection{Preliminaries --- page layout}
  100. % Let's announce ourselves as usual:
  101. %    \begin{macrocode}
  102. \typeout{Sub-style `web', version \fileversion\space of \filedate}
  103. %    \end{macrocode}
  104. % We don't want stretch between paragraphs.
  105. %    \begin{macrocode}
  106. \parskip \z@ 
  107. %    \end{macrocode}
  108. % \begin{macro}{\textwidth}\begin{macro}{\textheight}
  109. % \begin{macro}{\oddsidemargin} \begin{macro}{\evensidemargin}
  110. % The default page width should be large for \web\@.  This is for
  111. % non-Americans (A4)---if you want to alter the page dimensions with a
  112. % suitable style option put it {\em after\/} "web" in the
  113. % "\documentstyle" list.  The width here is too big for decently
  114. % readable text, but is
  115. % still less than the $6.5''$ of the original.  Note that there's no
  116. % point in trying to use "\marginpar" at
  117. % this width since the margins have disappeared!  The "twoside" option
  118. % will work sensibly if you care to use it.\DescribeMacro{twoside}  We
  119. % want to avoid doing this when typesetting the documenttation, hence
  120. % the test for "\DocInput".
  121. %    \begin{macrocode}
  122. \ifx\DocInput\undefined
  123. \ifcase \@ptsize
  124.    \textheight = 53 \baselineskip
  125.    \textheight = 47 \baselineskip
  126.    \textheight = 43 \baselineskip
  127. \fi  \advance \textheight by \topskip
  128. \textwidth=6.27in  \oddsidemargin=\z@  \evensidemargin=\z@
  129. %    \end{macrocode}
  130. % \end{macro}\end{macro}\end{macro}\end{macro}
  131. % We use the "myheadings" page style with headings containing module
  132. % information (see below).
  133. %    \begin{macrocode}
  134. \pagestyle{myheadings}
  135. %    \end{macrocode}
  136. % If we start off with a "\sectionmark" we won't miss the running
  137. % header off the first page where it should appear.
  138. %    \begin{macrocode}
  139. \ifx\DocInput\undefined \sectionmark{1} \fi
  140. %    \end{macrocode}
  141. % \subsubsection{Font selection}
  142. % \begin{macro}{\normal@font}
  143. % We have to check whether we're in the old or new font selection scheme
  144. % and set up appropriately.  "\normal@font" is invoked before the font
  145. % changes for identifiers, reserved words and strings to make sure
  146. % that they use the default series and shape in the new scheme.  This
  147. % is actually only necessary if "\id", "\res" or "\str" is used in
  148. % \TeX\ text that is being set in a different shape or series, not
  149. % normally in the code.  If you use the new selection scheme you can
  150. % do things like using Concrete or PostScript fonts easily.
  151. %    \begin{macrocode}
  152. \@ifundefined{selectfont}{%
  153.      \let\normal@font=\relax}   % old scheme
  154.    {% new scheme
  155.      \def\normal@font{\series \mediumseriesdefault 
  156.      \shape \normalshapedefault}}
  157. %    \end{macrocode}
  158. % \end{macro}
  159. % \subsection{Front matter}
  160. % We depart from the plain version here.  The first page (or pages, if
  161. % the contents are very long) is produced with the "titlepage"
  162. % environment.  The "\author", "\date" and
  163. % "\title" \DescribeMacro{\title} can be specified
  164. % as usual in \LaTeX\@.  Note that you now say
  165. % "\title{"\meta{title}"}" rather than "\def\title{"\meta{title}"}" as
  166. % in the plain version and this title will be used in the running
  167. % header. 
  168. % \begin{macro}{\@maketitle}
  169. % We'll re-define "\@maketitle" to include the "\topofcontents" and
  170. % "\botofcontents" information, with the contents information in the
  171. % middle.  The normal title, author and date will be put automatically
  172. % at the top---"\topofcontents" is extra.  You get the titling and
  173. % contents information automatically, since "\maketitle" is inserted
  174. % by \weave{} immediately after "\begin{document}".  If you want to
  175. % suppress it, "\let\maketitle=\relax" in the limbo part.
  176. % Of course, you have to make two
  177. % passes to get the contents printed, unlike the original plain
  178. % system.  This should not be much hardship as one usually reckons on
  179. % running \LaTeX{} at least twice.  (Putting the titlepage at the back
  180. % won't help, since the ".toc" file only exists after the ".aux" file
  181. % has been read on the secind pass.  One could change the standard
  182. % behaviour so that the ".toc" file was created at the end of the
  183. % first pass, I guess.)
  184. % We first test for "\DocInput" as above to
  185. % avoid messing things up when typesetting the documentation.
  186. %    \begin{macrocode}
  187. \ifx\DocInput\undefined
  188. \def\@maketitle{%
  189.   \newpage  \thispagestyle{empty} \null
  190.   \begin{center}
  191.   {\LARGE \@title \par}  \vskip 1.5em
  192.   {\large   \lineskip .5em
  193.     \begin{tabular}[t]{c} \@author  \end{tabular} \par}                   
  194.   \vskip 1em  {\large \@date}
  195.   \end{center}
  196.   \par   \vskip 1.5em
  197.   \topofcontents  \tableofcontents  \par  \botofcontents \newpage }
  198. %    \end{macrocode}
  199. %    \end{macro}
  200. % \begin{macro}{\maketitle}
  201. % We change "\maketitle" to avoid the "\thispagestyle{plain}" that it
  202. % otherwise contains, to set the page number to 1 at the end and to
  203. % avoid losing the definitions of "\@title" and "\@author".
  204. % ("\@title" is used in the running header.)
  205. %    \begin{macrocode}
  206. \ifx\DocInput\undefined
  207. \def\maketitle{%
  208.   \par \begingroup
  209.     \pagenumbering{roman}  \setcounter{page}{0}
  210.     \def\thefootnote{\fnsymbol{footnote}}
  211.     \def\@makefnmark{\hbox to \z@ {$^{\@thefnmark}$\hss}}   
  212.     \if@twocolumn  \twocolumn[\@maketitle]   
  213.     \else  \newpage  \global\@topnum\z@  \@maketitle  \fi
  214.     \@thanks
  215.   \endgroup
  216.   \setcounter{footnote}{0}  \pagenumbering{arabic}
  217.   \let\maketitle\relax  \let\@maketitle\relax
  218.   \gdef\@thanks{}\let\thanks\relax}
  219. %    \end{macrocode}
  220. %    \end{macro}
  221. % \begin{macro}{\@title} \begin{macro}{\@author}
  222. % We better define these in case they're not supplied:
  223. %    \begin{macrocode}
  224. \let\@title=\empty  \let\@author=\empty
  225. %    \end{macrocode}
  226. %    \end{macro}    \end{macro}
  227. % \begin{macro}{\tableofcontents}
  228. % "\tableofcontents" is re-defined to produce a header saying
  229. % ``Section'' and ``Page'' a bit like the plain version, although the
  230. % section (module) number is at the left.
  231. %    \begin{macrocode}
  232. \def\tableofcontents{%
  233.   \noindent Section \hfill Page \par  \@starttoc{toc}}
  234. %    \end{macrocode}
  235. %    \end{macro}
  236. % \begin{macro}{\topofcontents} \begin{macro}{\botofcontents}
  237. % The "\topofcontents" material that comes between the title\slash author
  238. % information and the contents list and the "\botofcontents" stuff
  239. % that comes after the contents list are empty initially.  I'm not
  240. % sure it's worth preserving them.
  241. %    \begin{macrocode}
  242. \def\topofcontents{}  \def\botofcontents{}
  243. %    \end{macrocode}
  244. %    \end{macro}    \end{macro}
  245. % \begin{macro}{\ttitlefont} \begin{macro}{\titlefont}
  246. % These are just for compatibility with the plain version---they
  247. % should probably go.
  248. %    \begin{macrocode}
  249. \let\ttitlefont=\tt  \let\titlefont=\rm
  250. %    \end{macrocode}
  251. %    \end{macro}    \end{macro}
  252. % \subsection{Prettyprinting stuff}
  253. % \subsubsection{Identifiers, reserved words and strings}
  254. %    \begin{macro}{\id}\begin{macro}{\ida}\begin{macro}{\idfont}
  255. % Multi-letter identifiers are set by the macro "\id" in font "\idfont",
  256. % which is italic by default i.e., \id{identifier}.
  257. % One-letter identifiers are
  258. % actually set by "\ida" in math italic as they are supposed to look
  259. % better that way (\ida{a} rather than \id{a}).
  260. %    \begin{macrocode}
  261. \newcommand{\id}[1]{\mbox{\idfont #1\/\kern.05em}}
  262. \newcommand{\ida}[1]{\mbox{$ #1 $}}
  263. \newcommand{\idfont}{\normal@font \it}
  264. %    \end{macrocode}
  265. %    \end{macro}    \end{macro}    \end{macro}
  266. %    \begin{macro}{\reservedfont}\begin{macro}{\res}
  267. %  Reserved words are set by macro "\res", using "\reservedfont" which
  268. %  is bold by default i.e., \res{reserved}.
  269. %    \begin{macrocode} 
  270. \newcommand{\reservedfont}{\normal@font \bf}
  271. \newcommand{\res}[1]{\mbox{\reservedfont#1\/}}
  272. %    \end{macrocode}
  273. %    \end{macro}\end{macro}
  274. %    \begin{macro}{\str}
  275. % Typewriter type is used for strings, set by "\str" i.e.,
  276. % \str{string}.  The definitions of the escaped characters 
  277. % are given below.  I don't understand why the ampersand is treated
  278. % like this, since "\&" is defined anyway, but quotes and "^" are
  279. % escaped to avoid 
  280. % ligatures.\footnote{{\tt \char`\^} and {\tt \char`\~} form ligatures
  281. % in PostScript virtual fonts as well as "'".}  It's necessary to do a
  282. % "\def" of "\^" rather than just 
  283. % "\let\^\CF" to avoid an error with the use of "\^" not matching its
  284. % definition.   Note the use of "\@tempa" below rather than "\XX" as
  285. % used in the same situation elsewhere---using "\XX", "\str" breaks if
  286. % it is used in, say, a comment.
  287. %    \begin{macrocode} 
  288. \def\str#1{%
  289.   \ifmmode \gdef\@tempa{\null$\null}\else \gdef\@tempa{}\fi
  290.   \@tempa {%
  291.   \let\\=\BS  \let\'=\RQ  \let\`=\LQ  \let\{=\LB  \let\}=\RB
  292.   \let\~=\TL  \let\ =\SP  \let\&=\AM  \def\^{{\tt \char`\^}}%
  293.   \leavevmode \normal@font\tt #1}\@tempa}
  294. %    \end{macrocode}
  295. %    \end{macro}
  296. % \begin{macro}{\AM} \begin{macro}{\BS} \begin{macro}{\LB}
  297. % \begin{macro}{\LQ} \begin{macro}{\RB} \begin{macro}{\UL}
  298. % \begin{macro}{\TL}
  299. % Here are the definitions of the control sequences for strings.  The
  300. % plain version redefined "\#", "\$", "\%" and "\^" globally.  "\$"
  301. % isn't used by awk or C \web s, and has been removed.  The others are
  302. % done only in code, using "\startcodehook" (below).
  303. %    \begin{macrocode}
  304. \chardef\AM=`\&                 % ampersand
  305. \chardef\BS=`\\                 % backslash
  306. \chardef\LB=`\{                 % left brace
  307. \def\LQ{{\tt\char'22}}          % left quote
  308. \chardef\RB=`\}                 % right brace
  309. \def\RQ{{\tt\char'23}}          % right quote
  310. \def\UL{{\tt\char`\_}}          % underline character in a string
  311. \def\TL{{\tt\char`\~}}          % tilde 
  312. %    \end{macrocode}
  313. %    \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
  314. %    \end{macro}
  315. % \begin{macro}{\SP}
  316. % Strings may be rather long and we want some way of breaking
  317. % them, so
  318. % "\SP" produces a visible space (\str{\SP}) and also adds a discretionary
  319. % break afterwords.  If a break occurs, the line is ended with a
  320. % backslash.  Spaces are probably the most sensible place to break
  321. % strings, especially if they are messages, but one could consider
  322. % doing the same thing for other of the macros above e.g., "\BS" might
  323. % check if the next character was "n" and insert a discretionary break
  324. % after that.
  325. %    \begin{macrocode} 
  326. \newcommand{\SP}{\char`\ \discretionary{\hbox{\char`\\}}{}{}}
  327. %    \end{macrocode}
  328. %    \end{macro}
  329. % \begin{macro}{\vstr}
  330. % This does a verbatim string (from "@=") using the existing \LaTeX
  331. % nology rather than the original definition to put a frame around it
  332. % (\vstr{string}). 
  333. %    \begin{macrocode}
  334. \newcommand{\vstr}[1]{\kern 2pt \fbox{\str{#1}}\kern 2pt}
  335. \setlength{\fboxsep}{2pt}
  336. %    \end{macrocode}
  337. %    \end{macro}
  338. % \begin{macro}{\const}
  339. % This looks after setting octal, hex or decimal constants.  The first
  340. % thing in its argument may be one of the control sequences in the
  341. % example on the left,
  342. % producing the result in the middle:
  343. % \[\begin{tabular}{lll}
  344. % "\const{\$10}" & $\const{\$10}$ & (long) \\
  345. % "\const{\_10}" & $\const{\_10}$ & (power of ten)\\
  346. % "\const{\~10}" & $\const{\~10}$ & (octal) \\
  347. % "\const{\^AB10}" & $\const{\^AB10}$ & (hex) \\
  348. % \end{tabular}\]
  349. % \DeleteShortVerb{\"}
  350. %    \begin{macrocode}
  351. \def\const#1{{%
  352.   \def\?{\kern.2em}%
  353.   \def\${\ell}% long
  354.   \def\_{\RealConstFormat{\aftergroup}}% power of ten
  355.   \def\~{\hbox{\rm \char'23\kern-.2em \it \aftergroup\?\aftergroup}}% octal
  356. %    \end{macrocode}
  357. % The \verb+"+ here was originally \verb+\char'175+ which,
  358. % unfortunately, is different in PostScript virtual fonts and Computer
  359. % Modern: 
  360. %    \begin{macrocode}
  361.   \def\^{\hbox{\rm "\tt \aftergroup}}% hex
  362.   #1}}                          % (\def{\const})
  363. %    \end{macrocode}
  364. %    \end{macro}
  365. % \MakeShortVerb{\"}
  366. %    \begin{macro}{\RealConstFormat}
  367. % I prefer to re-define the decimal style
  368. % to print as the more code-like `$\mbox{\rm e}10$'.  You can
  369. % do this by using the hook "\RealConstFormat" in your Spider "macros"
  370. % section: 
  371. % \begin{quote} "\newcommand{\RealConstFormat}{\mbox{\rm e}}" .\end{quote}
  372. % For a go at a Fortran web, I hacked the lexing so that an "e" or "d" in
  373. % a real or double-precision constant was transmitted verbatim into the
  374. % argument of "\const" instead of "\_" and re-defined "\const" to ensure
  375. % this was set in roman.
  376. %    \begin{macrocode}
  377. \newcommand{\RealConstFormat}{\cdot 10^}
  378. %    \end{macrocode}
  379. %    \end{macro}
  380. % \subsubsection{Indentation and breaks}
  381. % \begin{macro}{\ind}
  382. % This counter stores the current indentation in ems.
  383. %    \begin{macrocode} 
  384. \newcount\ind
  385. %    \end{macrocode}
  386. %    \end{macro}
  387. % \begin{macro}{\bak} \begin{macro}{\bakk}
  388. % These backspace one and two ems respectively.
  389. %    \begin{macrocode} 
  390. \newbox\bak  \setbox\bak=\hbox to \m@ne em{}
  391. \newbox\bakk \setbox\bakk=\hbox to -2em{}
  392. %    \end{macrocode}
  393. %    \end{macro}\end{macro}
  394. % \begin{macro}{\0}
  395. %  A forced break, as from "@/":
  396. %    \begin{macrocode}
  397. \def\0{%
  398.   \ifmmode
  399.     \ifinner$\par\hangindent\ind em\noindent\kern\ind em\ignorespaces$\fi
  400.   \else
  401.     \par\hangindent\ind em\noindent \kern\ind em\ignorespaces 
  402.   \fi}
  403. %    \end{macrocode}
  404. %    \end{macro}
  405. % \begin{macro}{\1}
  406. % Indent one more notch:
  407. %    \begin{macrocode}
  408. \newcommand{\1}{\global\advance\ind by 1 \hangindent\ind em}
  409. %    \end{macrocode}
  410. %    \end{macro}
  411. % \begin{macro}{\2}
  412. % Indent one less notch:
  413. %    \begin{macrocode}
  414. \newcommand{\2}{\global\advance\ind by \m@ne }
  415. %    \end{macrocode}
  416. %    \end{macro}
  417. % \begin{macro}{\3}
  418. %  An optional break within a statement, as from "@|":
  419. %    \begin{macrocode}
  420. \newcommand{\3}[1]{\hfil \penalty#10 \hfilneg}
  421. %    \end{macrocode}
  422. %    \end{macro}
  423. % \begin{macro}{\4}
  424. % Backspace one notch:
  425. %    \begin{macrocode}
  426. \newcommand{\4}{\copy\bak}
  427. %    \end{macrocode}
  428. %    \end{macro}
  429. % \begin{macro}{\5}
  430. % Optional break:
  431. %    \begin{macrocode}
  432. \newcommand{\5}{\hfil \penalty \m@ne  \hfilneg \kern 2.5em \copy\bakk
  433.   \ignorespaces} 
  434. %    \end{macrocode}
  435. %    \end{macro}
  436. % \begin{macro}{\6}
  437. % A forced break with no indentation:
  438. %    \begin{macrocode}
  439. \def\6{\ifmmode \else \par
  440.   \hangindent\ind em\startline \ignorespaces \fi}
  441. %    \end{macrocode}
  442. %    \end{macro}
  443. % \begin{macro}{\startline}
  444. % This is used by "\code" as well as "\6" above.
  445. %    \begin{macrocode}
  446. \def\startline{\noindent \count255=\ind \advance\count255 by -2
  447.   \hskip\count255 em}
  448. %    \end{macrocode}
  449. %    \end{macro}
  450. % \begin{macro}{\7}
  451. %  A forced break and a little extra vertical space, as from "@#": 
  452. %    \begin{macrocode}
  453. \newcommand{\7}{\Y\6}
  454. %    \end{macrocode}
  455. %    \end{macro}
  456. % \begin{macro}{\8}
  457. % No indentation.  It works only in code, not in "|"\dots"|".
  458. %    \begin{macrocode}
  459. \newcommand{\8}{\unskip}
  460. %    \end{macrocode}
  461. %    \end{macro}
  462. % \begin{macro}{\J}
  463. % \tangle's join operation ("@&"):
  464. %    \begin{macrocode}
  465. \newcommand{\J}{\str{@\&}}
  466. %    \end{macrocode}
  467. %    \end{macro}
  468. % \begin{macro}{\C}
  469. % This looks after comments.  The hooks are inserted because comments
  470. % aren't code (see below).
  471. %    \begin{macrocode}
  472. \def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi
  473.    \XX \hfil \penalty \m@ne\hfilneg\quad % original spider
  474.    $\commentbegin\,$\endcodehook{#1}\startcodehook$\,
  475.    \commentend$\XX}
  476. %    \end{macrocode}
  477. % \end{macro}
  478. %    \subsection{Modules}
  479. % \begin{macro}{\onmaybe} \begin{macro}{\maybe} \begin{macro}{\ifon}
  480. % These switches are concerned with only printing changed sections if
  481. % so desired.
  482. %    \begin{macrocode}
  483. \def\onmaybe{\let\ifon=\maybe}  \let\maybe=\iftrue  \newif\ifon
  484. %    \end{macrocode}
  485. %    \end{macro}\end{macro}\end{macro}
  486. %    \begin{macro}{\M}
  487. % Beginning of an un-starred section:
  488. %    \begin{macrocode}
  489. \outer\def\M#1.{%
  490.   \MN#1.\ifon\vfil\penalty-100\vfilneg
  491.   \vskip12ptminus3pt \startsection \ignorespaces}
  492. %    \end{macrocode}
  493. % \end{macro}
  494. %    \begin{macro}{\startsection}  \begin{macro}{\lapstar}
  495. % Some auxilliary definitions:
  496. %    \begin{macrocode}
  497. \def\startsection{\Q \noindent {\let\*=\lapstar \bf \modstar.\quad }}
  498. \newcommand{\lapstar}{\rlap{*}}
  499. %    \end{macrocode}
  500. %    \end{macro}    \end{macro}
  501. %    \begin{macro}{\N}
  502. % This introduces a starred section (where "#2" is the title).   We
  503. % have to check the title with "\headcheck" for a leading 
  504. % character indicating a subsection.  Then we write a contents entry,
  505. % change the running header and set the title in bold.  "\old@S" is
  506. % used in the header rather than "\S" since "\S" is probably
  507. % wrongly-defined at this point (see below).
  508. %    \begin{macrocode}
  509. \outer\def\N#1.#2.{%
  510.   \MN#1.\headcheck#2\headcheck
  511.   \typeout{*\modno} % progress report
  512.   \addcontentsline{toc}{\headcheck@type}
  513.     {\hbox to 2em{\modno\hfill} \quad \theopen \relax \themodtitle}
  514.   \markboth{% running headline
  515.     {\protect\small \qquad\uppercase{\ignorespaces\themodtitle}}
  516.       \hfill {\protect\small \@title}\qquad{\rm \old@S \modno}}
  517.     {\rm \old@S \modno\qquad {\protect\small \@title}\hfill
  518.       {\protect\small \uppercase{\ignorespaces\themodtitle\qquad}}}
  519.   \ifon\startsection {\bf \ignorespaces \themodtitle.\quad }\ignorespaces}
  520. %    \end{macrocode}
  521. % \end{macro}
  522. % \begin{macro}{\MN}
  523. % Here is some common code for "\M" and "\N"\@.
  524. % It sets
  525. % "\sectionmark" for the headers and defines cross-referencing
  526. % information for the current module.
  527. % It also
  528. % looks after the decision about whether or not to set this module if it
  529. % is not starred.
  530. %    \begin{macrocode}
  531. \def\MN#1.{%
  532.   \par {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}%
  533.   \ifx\modno\modstar \onmaybe \else \ontrue \fi 
  534.   \sectionmark{\modno} 
  535. %    \end{macrocode}
  536. % The following code for setting the currentlabel to the module number
  537. % is a variation on that in {\tt latex.tex}.
  538. %    \begin{macrocode}
  539.   \let\@tempa\protect
  540.   \def\protect{\noexpand\protect\noexpand}%
  541.   \def\@currentlabel{#1}%
  542.   \let\protect\@tempa} % def\MN
  543. %    \end{macrocode}
  544. % \end{macro}
  545. % \begin{macro}{\note} \begin{macro}{\A}
  546. % Auxilliary macros.  "\A" is for cross-references for multiply
  547. % defined section names.
  548. %    \begin{macrocode}
  549. \def\note#1#2.{\Y \noindent {\hangindent 2em \footnotesize
  550.   \baselineskip 10pt#1 #2.\par}}
  551. \newcommand{\A}{\note{See also}}
  552. %    \end{macrocode}
  553. % \end{macro} \end{macro}
  554. % \subsubsection{Processing special section headings}
  555. % This complicated stuff, introduced with \spider{} and modified for the
  556. % \LaTeX{} version, is to allow an inital =, 1, 2, 3 or 4 in 
  557. % starred module titles to indicate a hierarchy.  Their effect is as follows:
  558. % \[ \begin{tabular}{c|c|c}
  559. % Introduction & Page eject? & Indentation in contents\\ \hline
  560. % "@*=" & yes & 0 \\
  561. % "@*1" & yes & 2 em \\
  562. % "@*2" & no  & 2 em \\
  563. % "@*3" & yes & 4 em \\
  564. % "@*4" & no  & 4 em \\
  565. % \end{tabular} \]
  566. % "@*=" also suppresses a following page eject and emboldens the
  567. % table of contents entry and puts some extra vertical space before
  568. % it.  Normal starred sections have no indentation in the contents and
  569. % don't do anything special about page breaks.
  570. % \begin{macro}{\l@part} \begin{macro}{\l@norm} \begin{macro}{\l@num}
  571. % Two new sorts of contents entry are defined here and the `part'
  572. % type re-defined.  (See "latex.tex" for details of how this works.)
  573. % "\l@part" determines the t.o.c.\ entry for a "@*=" section,
  574. % "\l@norm" the entry for a normal starred section and "\l@num" that
  575. % for a numbered section.  Some penalties are inserted (the normal
  576. % values for the main style) in case the t.o.c.\ extends over more
  577. % than one page.  The "\headcheck@type" definition is used in the
  578. % sectioning commands to write the t.o.c.\ entry.
  579. %    \begin{macrocode}
  580. \def\l@part{\addpenalty{\@secpenalty}
  581.    \addvspace{3pt plus 1pt}     % space above part line
  582.    \@dottedtocline{0}{\z@ }{4em}}
  583. \def\l@norm{\addpenalty{\@secpenalty}
  584.    \@dottedtocline{0}{\z@ }{4em}}
  585. \def\l@num{\@dottedtocline{0}{0em}{4em}}
  586. %    \end{macrocode}
  587. % \end{macro}\end{macro}\end{macro}
  588. % \begin{macro}{\ifcancel} \begin{macro}{\ifnextchar}
  589. % \begin{macro}{\ifnch} \begin{macro}{\makethechar}
  590. % Here's the tricky stuff, presented without further comment!
  591. %    \begin{macrocode}
  592. \newif\ifcancel  \cancelfalse
  593. \def\ifnextchar#1#2#3{%
  594.   \let\@tempe=#1\def\@tempa{#2}\def\@tempb{#3}\@ifnch}
  595. \def\@ifnch{%
  596.   \ifx \@tempc \@tempe\let\@tempd\@tempa
  597.   \else \let\@tempd\@tempb
  598.   \fi
  599.   \@tempd}
  600. \def\makethechar#1{\let\@tempc=#1}
  601. %    \end{macrocode}
  602. % \end{macro} \end{macro} \end{macro} \end{macro}
  603. % \begin{macro}{\headcheck}
  604. %    \begin{macrocode}
  605. \def\headcheck#1#2\headcheck{%
  606.   \makethechar{#1}%
  607.   \def\theskipper{\vfil\penalty-100 % skip before new module
  608.     \vfilneg\vskip12ptminus3pt}%
  609.   \def\theopen{}% opening skip in toc entry
  610.   \def\thetocskip{}% vertical skip before toc entry
  611.   \def\themodtitle{{#2}}%
  612.   \def\headcheck@type{num}%
  613.   \ifnextchar={%
  614.     \def\theskipper{\newpage}  \canceltrue
  615.     \def\headcheck@type{part}       \def\theopen{\bf}%
  616.     \def\thetocskip{\vskip 3pt plus 1in \penalty-100 
  617.       \vskip \z@  plus -1in}% 
  618.     }{\ifnextchar1{%
  619.       \cancelfalse      \def\theskipper{\newpage}%
  620.       \def\theopen{\hskip2em}%
  621.     }{\ifnextchar2{%
  622.       \cancelfalse      \def\theopen{\hskip2em}%
  623.     }{\ifnextchar3{%
  624.       \cancelfalse      \def\theskipper{\newpage}%
  625.       \def\theopen{\hskip4em}%
  626.     }{\ifnextchar4{%
  627.       \cancelfalse      \def\theopen{\hskip4em}%
  628.     }{% else 
  629.       \ifcancel\else \def\theskipper{\newpage}\fi
  630.       \cancelfalse      \def\headcheck@type{norm}%
  631.       \def\themodtitle{#1{#2}}%
  632.     }}}}}%
  633.     \theskipper }
  634. %    \end{macrocode}
  635. % \end{macro}
  636. %    \subsubsection{Starting and ending code sections}
  637. % \begin{macro}{\code}
  638. % This takes us into code mode.  The old version used infinite hyphen
  639. % penalty which stopped the discretionary breaks in strings.  Extra
  640. % space is put after ";" with the "\sfcode". 
  641. %    \begin{macrocode}
  642. \newcommand{\code}{%
  643.   \rightskip=\z@  plus 100pt minus 10pt
  644.   \sfcode`;=3000    \pretolerance \@M
  645.   \hyphenpenalty 9999  \exhyphenpenalty \@M
  646.   \global\ind=2 \1 \startline
  647. %    \end{macrocode}
  648. % \DescribeMacro{\@}
  649. % The original says that every web must define "\?", where "?" is the
  650. % at-sign.  Since "\@" is used for end-of-sentence space in \LaTeX, we
  651. % make sure this is only done in code mode.  We need the old and new
  652. % definitions, "\old@" and "\code@", between which to switch.
  653. % \spider{} unfortunately uses "\S" instead of "\equiv" and the awk
  654. % and C \web s assume that "\%" and "\#" translate to typewriter
  655. % versions, so we have to define these properly in code mode too.
  656. % \DescribeMacro{\startcodehook} \DescribeMacro{\endcodehook}
  657. % For convenience, we define token registers
  658. % "\startcodehook" and "\endcodehook" for this sort of purpose when we
  659. % go into and out of code mode.  These might be altered by the
  660. % \spider\ description if appropriate.
  661. %    \begin{macrocode}
  662.   \startcodehook} % \def\code
  663. %    \end{macrocode}
  664. % \end{macro}
  665. % \begin{macro}{\old@}\begin{macro}{\code@}\begin{macro}{\old@S}
  666. % \begin{macro}{\old@percent} \begin{macro}{\old@hash}
  667. % Let's store the original definitions of these:
  668. %    \begin{macrocode}
  669. \let\old@=\@   \let\old@S=\S  \let\old@percent=\%  
  670. \let\old@hash=\#
  671. %    \end{macrocode}
  672. %    \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
  673. % \begin{macro}{\code@}\begin{macro}{\tt@percent}\begin{macro}{\tt@hash}
  674. % And here are replacements for use in code mode.
  675. %    \begin{macrocode}
  676. \chardef\code@=`\@  
  677. \def\tt@percent{\hbox{\tt\char`\%}}  \def\tt@hash{\hbox{\tt\char`\#}}
  678. %    \end{macrocode}
  679. % \end{macro}\end{macro}\end{macro}
  680. % \begin{macro}{\startcodehook}\begin{macro}{\endcodehook}
  681. % Here are the hooks.  Should these be token registers?
  682. %    \begin{macrocode}  
  683. \def\startcodehook{\let\@=\code@  \let\S=\equiv  \let\%=\tt@percent
  684.   \let\#=\tt@hash  \def\^{\hbox{\tt\char`\^}}}
  685. \def\endcodehook{\let\@=\old@  \let\S=\old@S  \let\%=\old@percent
  686.   \let\#=\old@hash  \def\^##1{{\accent94 ##1}}}
  687. %    \end{macrocode}
  688. %  \end{macro}\end{macro}
  689. % \begin{macro}{\Q}
  690. % This gets us out of code mode, setting things back to normal.
  691. %    \begin{macrocode}
  692. \def\Q{\rightskip=\z@   \sfcode`;=1500  \pretolerance 200  
  693.   \endcodehook}
  694. %    \end{macrocode}
  695. %    \end{macro}
  696. % \begin{macro}{\CD} \begin{macro}{\DC}
  697. % Web text in "|"\dots"|" is woven into text surrounded by
  698. % "\CD"\dots"\DC"\@.  The original definition didn't bother with the
  699. % grouping if not in math mode, but it's convenient now that the hooks
  700. % need to be added.
  701. %    \begin{macrocode}
  702. \def\DC{\endcodehook \egroup}
  703. \def\CD{\relax
  704.   \ifmmode \hbox\fi \bgroup \startcodehook}
  705. %    \end{macrocode}
  706. % \end{macro}\end{macro}
  707. % \begin{macro}{\U}
  708. % This provides a cross-reference for uses of sections.
  709. %    \begin{macrocode}
  710. \newcommand{\U}{\note{This code is used in}} 
  711. %    \end{macrocode}
  712. %    \end{macro}
  713. % \begin{macro}{\X}
  714. % This does modules which introduce the code.  Note the usage:
  715. % "\X"\meta{module number}":"\meta{module name}"\X".
  716. %    \begin{macrocode}
  717. \def\X#1:#2\X{%
  718.   \ifmmode \gdef\XX{\null$\null}\else \gdef\XX{}\fi
  719.   \XX$\langle\,$#2{\footnotesize \kern.5em #1}$\,\rangle$\XX }
  720. %    \end{macrocode}
  721. %    \end{macro}
  722. % \begin{macro}{\XF}
  723. % This is for a file module (from "@("):
  724. %    \begin{macrocode}
  725. \def\XF#1:#2\XF{%
  726.   \ifmmode \gdef\XX{\null$\null}\else \gdef\XX{}\fi
  727.   \XX {\tt (#2{\footnotesize \kern.5em #1})}\XX}
  728. %    \end{macrocode}
  729. %    \end{macro}
  730. % \begin{macro}{\Y} \begin{macro}{\yskip}
  731. % This does a vertical skip by "\yskip", used in "\note" and "\7".
  732. %    \begin{macrocode}
  733. \newcommand{\Y}{\par\yskip}
  734. \let\yskip=\smallskip
  735. %    \end{macrocode}
  736. %    \end{macro}\end{macro}
  737. %    
  738. % \subsection{Definitions and formats}
  739. % \begin{macro}{\D} \begin{macro}{\F} \begin{macro}{\defin}
  740. % "\D" and "\F" deal with macro and format definitions from "@d" and
  741. % "@f" respectively.
  742. %    \begin{macrocode}
  743. \newcommand{\D}{\defin{define}} % macro definition
  744. \newcommand{\F}{\defin{format}} % format definition
  745. \newcommand{\defin}[1]{\global\advance\ind by 2 \1\res{#1 }}
  746. %    \end{macrocode}
  747. %    \end{macro}\end{macro}\end{macro}
  748. % \subsection{Miscellaneous symbols}
  749. % \begin{macro}{\DO} \begin{macro}{\G} \begin{macro}{\I}
  750. % \begin{macro}{\K} \begin{macro}{\L} \begin{macro}{\R} 
  751. % \begin{macro}{\TI} \begin{macro}{\V} \begin{macro}{\W}
  752. % Here are some miscellaneous symbols.  I think these should really be
  753. % defined in the \spider\ descriptions that need them, but they are
  754. % assumed by the current webs.
  755. %    \begin{macrocode}
  756. \newcommand{\DO}{\hbox{\sl\char'044}}    % slant dollar sign (used by awkweb)
  757. \let\G=\ge                      % greater than or equal sign
  758. \let\I=\ne                      % unequal sign
  759. \let\K=\gets                    % left arrow
  760. \let\L=\le                      % less than or equal sign
  761. \let\R=\lnot                    % logical not
  762. \let\TI=\sim                    % tilde
  763. \let\V=\lor                     % logical or
  764. \let\W=\land                    % logical and
  765. %    \end{macrocode}
  766. %    \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
  767. %    \end{macro}\end{macro}\end{macro}
  768. % \begin{macro}{\vert} \begin{macro}{\amp} \begin{macro}{\PP}
  769. % \begin{macro}{\*} 
  770. % And some more:  (n.b., the plain \TeX{} definitions of "\vert"
  771. % and "\*" are over-written, as expected by spidery \weave---maybe this
  772. % should be changed).
  773. %    \begin{macrocode}
  774. \def\vert{|}   \let\amp=\&   \let\PP=\P   \let\*=*
  775. %    \end{macrocode}
  776. %    \end{macro}\end{macro}\end{macro}\end{macro}
  777. % \begin{macro}{\AT!}
  778. % \changes{v1.2}{10/6/91}{Re-instate trailing !.}
  779. % This is the `at sign in control
  780. % text'.  I dn't know why it has the trailing "!", but it apears to
  781. % have bene intentional in the plain version.
  782. %    \begin{macrocode}
  783. \def\AT!{@}
  784. %    \end{macrocode} 
  785. %    \end{macro}
  786. % \subsection{Indexing}
  787. % \begin{macro}{\ch}
  788. % This is used trivially at the start of the index in the case of
  789. % changes: 
  790. %    \begin{macrocode} 
  791. \def\ch{\note{The following sections were changed by the change file:}
  792.   \let\*=\relax}
  793. %    \end{macrocode}
  794. %    \end{macro}
  795. % \begin{macro}{\inx} \begin{macro}{\:}
  796. % The index is set in two-column mode.
  797. % Each item in each index is introduced by "\:".  This is a \LaTeX{}
  798. % macro but is unlikely to get used in the index and so is preserved
  799. % from the original.
  800. %    \begin{macrocode}
  801. \def\inx{%
  802.   \typeout{Index:}
  803.   \begin{multicols}{2}
  804.   \parskip \z@  plus .5pt
  805.   \parfillskip \z@  plus .6\hsize % try to avoid almost empty lines
  806.   \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
  807.   \rm  \tolerance \@M  \let\*=\lapstar
  808.   \hyphenpenalty \@M \parindent=\z@  }
  809. %    \end{macrocode}
  810. % \end{macro}\end{macro}
  811. %    \begin{macro}{\fin}
  812. % This finishes off the name index and starts off the module index.
  813. % "\:" acts as in "\inx".  The modules may be
  814. % qualified with "\U", which cross-references section uses.  The page
  815. % header is changed appropriately.
  816. %    \begin{macrocode}
  817. \def\fin{%
  818.   \end{multicols}  \newpage
  819.   \parfillskip \z@  plus 1fil
  820.   \markboth{{\protect\small NAMES OF THE SECTIONS}\hfill 
  821.       {\protect\small\@title}}
  822.     {{\protect\small\@title}\hfill
  823.     {\protect\small NAMES OF THE SECTIONS\quad}}
  824.   \typeout{Section names:}
  825.   \def\note##1##2.{\quad{\footnotesize##1 ##2.}}
  826.   \def\U{\note{Used in}}%
  827.   \def\:{\par\hangindent 2em}\let\*=*}
  828. %    \end{macrocode}
  829. %    \end{macro}
  830. % \begin{macro}{\con}
  831. % This finishes everything off, rather trivially.  (It used to make
  832. % the contents page.)
  833. %    \begin{macrocode}
  834. \newcommand{\con}{\end{document}}
  835. %    \end{macrocode}
  836. %    \end{macro}
  837. % \subsection{Including other files}
  838. % \DescribeEnv{multicols}
  839. % We need the {\tt multicols} environment to make a two-column index
  840. % without a forced page break.
  841. %    \begin{macrocode}
  842. \input{multicol.sty}
  843. %    \end{macrocode}
  844. % \DescribeMacro{\webmacs}
  845. % Finally we include the macros defined by \spider.  Doing things this way
  846. % means that \spider{} can override things done in this file for the
  847. % \web{} system of a particular language (like the
  848. % definition of "\res", for instance) and the limbo section can do
  849. % further overriding for a particular web file.  If we're using this
  850. % file to document itself, "\webmacs" should have been defined in the
  851. % driver file to be "null"!
  852. %    \begin{macrocode}
  853. \input{\webmacs}
  854. %    \end{macrocode}
  855. % "\webmacs" is no further use and we might as well save the space.
  856. %    \begin{macrocode}
  857. \let\webmacs=\empty
  858. %    \end{macrocode}
  859. % \appendix
  860. % \section{Changes from the plain version}\label{changes}
  861. % \begin{description}
  862. % \item[{\tt \BS.}] becomes "\str";
  863. % \item[{\tt \BS\char`\^}] has been removed from the global
  864. % definitions (where it was assumed by the "c.spider" translation for
  865. % "^") and put in limbo in "weave.ch";
  866. % \item[{\tt \BS\%}, {\tt \BS\#} and {\tt \BS\$}] also removed from global
  867. % definitions and put in "\startcodehook"; 
  868. % \item[{\tt \BS\char`\~}] removed globally since it doesn't seem to be used;
  869. % \item[{\tt \BS\BS} and {\tt \BS|}] become "\id" and "\ida" respectively;
  870. % \item[{\tt \BS\&}] becomes "\res";
  871. % \item[{\tt \BS B} and {\tt \BS T}] (for controlled comments) removed
  872. % since no controlled comments in \spider;
  873. % \item[{\tt \BS)}] (string pool check sum) removed;
  874. % \item[{\tt \BS]}] (sign for forced line break) appears not be be
  875. % used, so removed;
  876. % \item[{\tt \BS=}] becomes "\vstr";
  877. % \item[{\tt \BS H}] (hat) removed since it seems not to be used and
  878. % clashes with \LaTeX;
  879. % \item[{\tt \BS Z}] replaced by \LaTeX{} contents stuff;
  880. % \item[{\tt \BS lheader} and {\tt \BS rheader}] replaced by \LaTeX{} marks;
  881. % \item[output routine stuff] all gone;
  882. % \item[{\tt \BS rhead}] no longer relevant---use the \LaTeX{} mark
  883. % mechanism; 
  884. % \item[{\tt \BS title}] should be called as a macro with the title as
  885. % its argument rather than "\def"ed; 
  886. % \item[{\tt \BS contentspagenumber}, {\tt \BS contentsfile} and {\tt
  887. % \BS readcontents}] no longer relevant;
  888. % \item[{\tt \BS pagewidth}, {\tt \BS pageheight} and {\tt \BS
  889. % fullpageheight}] no longer relevant---use the \LaTeX\ equivalents;
  890. % \item[{\tt \BS pageshift}] no longer relevant---use "twoside" option;
  891. % \item[verbatim macros] no longer relevant;
  892. % \item[{\tt \BS iftitle}] removed---use "\pagestyle{empty}" to
  893. % suppress page header.
  894. % \end{description}
  895. % \begin{thebibliography}{1}
  896. % \bibitem{spider} N. Ramsey, {\sl Comm. ACM}, {\bf 32} (1989) 1051
  897. % \end{thebibliography}
  898.